//
//  ArduinoCom.h
//  ArdiunoTest
//
//  Created by Blossom on 10-11-17.
//  Copyright 2010 Miles Thorogood, greenmeat.net. All rights reserved.
//

#import <Cocoa/Cocoa.h>

// import IOKit headers
#include <IOKit/IOKitLib.h>
#include <IOKit/serial/IOSerialKeys.h>
#include <IOKit/IOBSD.h>
#include <IOKit/serial/ioss.h>
#include <sys/ioctl.h>


@interface ArduinoCom : NSObject {
	int serialFileDescriptor; // file handle to the serial port
	struct termios gOriginalTTYAttrs; // Hold the original termios attributes so we can reset them on quit ( best practice )
	bool readThreadRunning;
	
	id delegate ;
}

- (NSString *) openSerialPort: (NSString *)serialPortFile baud: (speed_t)baudRate;
- (void)appendToIncomingText: (id) text;
- (void)incomingTextUpdateThread: (NSThread *) parentThread;
//- (void) refreshSerialList: (NSString *) selectedText;
//- (void) writeString: (NSString *) str;
//- (void) writeByte: (uint8_t *) val;

/* ---------------------------------
 Delagate methods
 ---------------------------------*/
- (void)setDelegate:(id)aDelegate ;
- (void) delegatedMethod ;
- (void) presentMethod ;
- (void) absentMethod ;

@end

/* ---------------------------------
 Delegate interface
 ---------------------------------*/
@interface NSObject(DIVARequestDelegateMethods)
- (void) arduinoPresentCallback:(ArduinoCom *)myArduinoRequest ;
- (void) arduinoAbsentCallback:(ArduinoCom *)myArduinoRequest ;
@end